<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>CSS导航栏</title>
  <style type="text/css">
      * {
          margin: 0;
          padding: 0;
      }

      .nav {
          width: 500px;
          height: 30px;
          position: relative;
          margin: 100px auto;
          list-style-type: none;
          font-size: 16px;
      }

      .nav li {
          width: calc(100% / 5);
          height: 100%;
          line-height: 30px;
          float: left;
          background: #ff6b81;
          color: white;
          transition-property: background;
          transition-duration: .5s;
          text-align: center;
          cursor: pointer;
      }

      .nav li:hover {
          background: #ff4757;
      }
      /*  显示边框*/
      .nav li:last-child:after {
          width: 100px;
          height: 3px;
          position: absolute;
          content: "";
          background: #ffa502;
          left: 0;
          bottom: 0;
          transition: all .5s;
      }
      .nav li:nth-of-type(1):hover ~ li.line:after{
          left: 0;
      }
      .nav li:nth-of-type(2):hover ~ li.line:after{
          left: 100px;
      }
      .nav li:nth-of-type(3):hover ~ li.line:after{
          left: 200px;
      }
      .nav li:nth-of-type(4):hover ~ li.line:after{
          left: 300px;
      }
      .nav li:nth-of-type(5):hover:after{
          left: 400px;
      }


  </style>
</head>
<body>
<ul class="nav">
  <li>菜单1</li>
  <li>菜单2</li>
  <li>菜单3</li>
  <li>菜单4</li>
  <li class="line">菜单5</li>
</ul>
</body>
</html>